<template>
	<view>
		<view v-if="list.length != 0">
			<u-cell-group v-for="(item, index) in list" :key="index">
				<u-cell size="large" :title="item.nickname">
					<view slot="value">
						<view class="managetag" @click="manageHandel(item.applyId)">审核</view>
					</view>
				</u-cell>
			</u-cell-group>
		</view>

		<view v-else>
			<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
			</u-empty>
		</view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
import { applyList, reviewUser } from '@/api/api.js'
import { mapState } from 'vuex'
export default {
	data() {
		return {
			list: [],
		}
	},
	computed: {
		...mapState(["teamList"])
	},
	onShow() {
		this.getApplyList()
		console.log("11")
	},
	methods: {
		// 查询申请列表
		getApplyList() {
			this.teamList.forEach(e => {
				//查询我创建的团队申请列表
				if (e.role == 'OWNER') {
					applyList(e.teamId).then(res => {
						this.list = res.data
					})
				}
			})
		},
		//审核
		manageHandel(applyId) {
			console.log(applyId)
			reviewUser(applyId).then(res => {
				if (res.code == 200) {
					this.$refs.uToast.show({
						type: 'success',
						message: "审核成功",
					})
				} else {
					this.$refs.uToast.show({
						type: 'error',
						message: res.msg,
					})
				}
				this.getApplyList()
			})
		},
	}
}
</script>

<style>
.managetag {
	display: inline-block;
	width: 100rpx;
	height: 40rpx;
	border-radius: 10rpx;
	line-height: 40rpx;
	text-align: center;
	border: 1rpx solid #4d9dff;
	color: #4d9dff;
	margin: 0 20rpx;
	font-size: 14px;
}
</style>
